package com.example.kotlin01

/**
 *1.主构造函数
 * constructor在没有修饰符或者注解的时候 可以省略
 */
class Point constructor(val x: Int, val y: Int) {
    private var nativeX: Int = x + 1
    private var nativeY: Int = y + 2

    init {
        println("x is $x and y is $y")
        println("nativeX is $nativeX and nativeY is $nativeY")
    }

    constructor(a: Int) : this(a + 1, a + 2) {
        println("次构造函数的值  a is $a")

    }

    constructor(b: Long) : this(b.toInt() + 3) {
        println("次构造函数的值  b is $b")
    }
}

fun main() {
    //调用主构造函数
    //Point(1, 2)
    //调用次构造函数1
    //Point(1)
//调用次构造函数2
    Point(2L)
}